package com.woniuxy.controller;

import java.security.Principal;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;

import com.woniuxy.dto.PageDto;
import com.woniuxy.entity.Log;
import com.woniuxy.entity.User;
import com.woniuxy.service.LogService;
import com.woniuxy.utils.ResultUtil;
/*import com.woniuxy.service.LogService;*/

@RestController
@RequestMapping("/log")
public class LogController {
	
	@Autowired
	LogService logservice;
	
	
	
	
	@RequestMapping("/findAllnews")
	public  PageDto<Log> findAllByuid( int page,HttpServletRequest request){
		//System.out.println("dasda进来了");
		
		
		
		Subject currentUser = SecurityUtils.getSubject();
		Session session = currentUser.getSession();
		User user  = (User)session.getAttribute("user");
		
		int uid= user.getU_id();
		System.out.println(uid);
		/*String uname = user.getAccount();
		System.out.println("uname:"+uname);*/
		Principal principal = request.getUserPrincipal();
		User  user2  = new User().setAccount(principal.getName());
		
		PageDto<Log> alog = logservice.findAllByuid(uid, page,user2.getAccount()) ;

		return alog;
		
	}
	
	
}
